import type {Router} from 'vue-router';
import nProgress from 'nprogress';

export function setupRouterGuard(router: Router) {
  createProgressGuard(router);
}

// 进度条
export function createProgressGuard(router: Router) {
  router.beforeEach(async (to) => {
    console.log('beforeEach', nProgress);
    nProgress.start();
  });

  router.afterEach(async () => {
    nProgress.done();
    console.log('afterEach', nProgress);
  });
}
